<!--banner图-->
<template>
  <div class="app-container">
    <div class="content-container">
      <div class="query-conditions">
        <div class="query-input">

        </div>
      </div>
      <div class="main-content">
        <el-row>
          <el-col :span="24">
            <div class="tables-content">
              <el-table
                :data="tableDataList"
                ref="tableDataRef"
                border
                max-height="calc(100vh - 171px)"
                height="calc(100vh - 171px)"
                :header-cell-style="{textAlign: 'center'}"
                size="small"
              >
                <el-table-column label="序号" type="index" show-overflow-tooltip/>
                <el-table-column prop="name" label="名称" align="center" show-overflow-tooltip/>
                <el-table-column prop="image" label="图片" align="center"
                                 show-overflow-tooltip/>
                <el-table-column prop="tag" label="模块哦" align="center"
                                 show-overflow-tooltip/>
                <el-table-column label="操作" width="120px">
                  <template slot-scope="scope">
                    <el-button type="text" size="mini" @click="updateImage(scope.row)">修改</el-button>
                  </template>
                </el-table-column>
              </el-table>

            </div>
            <div class="pagination-content">

            </div>
          </el-col>
        </el-row>
      </div>
    </div>
    <el-dialog
      :title="title"
      :visible.sync="imageOpen"
      :close-on-press-escape="false"
      :close-on-click-modal="false"
      width="30%"
      append-to-body>
      <el-form ref="form" :model="form" label-width="80px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="名称" prop="name">
              <el-input v-model="form.name" disabled placeholder="请输入公告标题"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="图片" prop="image">
              <el-input v-model="form.image"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>
import {getAllBannerList,getBannerList,updateBanner} from '@/api/user'

export default {
  name: "UserIndex",
  data() {
    return {
      // 查询条件
      queryParams: {},
      tableDataList: [],
      imageOpen: false,
      title: '',
      form: {},
    }
  },
  created() {
    this.getList()
  },
  methods: {
    // 请求数据
    getList() {
      let dataObj = {}
      getAllBannerList(dataObj).then(res => {
        this.tableDataList = res.data
      })
    },
    // 查询条件
    handleQuery() {
    },
    // 修改图片信息
    updateImage(row) {
      this.imageOpen = true
      getBannerList({name:row.name}).then(res => {
        this.form = res.data
      })
    },
    submitForm() {
      let objData = {
        name: this.form.name,
        image: this.form.image
      }
      updateBanner(objData).then(res => {
        this.imageOpen = false
        this.getList()
        this.msgSuccess('修改成功')
      }).catch(err => {
        this.imageOpen = false
      })
    },
    cancel() {
      this.imageOpen = false
    },
  },
}
</script>

<style scoped>

</style>
